{extend name="base" /} {block name="body"}

<div class="admin-main">




    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="layui-this">添加站内导航</li>
            <li>添加自定义链接</li>
        </ul>



        <div class="layui-tab-content">

            <div class="layui-tab-item layui-show">
                <form class="layui-form form-container" data-url="{:url('admin/navcms/save')}" localtion-url="{:url('navcms/index')}">


                    <input type="hidden" name="sid" value="1" title="内部">
                    <div class="layui-form-item">
                            <label class="layui-form-label">导航位置</label>
                            <div class="layui-input-inline" style="width:300px">
                                <input type="radio" name="pid" value="1" title="顶部" checked="checked">
                                <input type="radio" name="pid" value="0" title="底部">
                                <input type="radio" name="pid" value="2" title="首页中部">
                            </div>
                        </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">上级分类</label>


                        <div class="layui-input-inline">
                            <select name="tid">
                           <div>
                                <option value="0">无</option>
                              {volist name="nav_level_list[1]" id="vo"}
                            <option value="{$vo.id}">{neq name="vo.level" value="1"}|{php}for($i=1;$i<$vo['level'];$i++){echo ' --';}{/php}{/neq}{$vo.name}</option>
                              {/volist}
                            </div>
                              </select>
                            
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">系统栏目</label>
                        <div class="layui-input-inline">
                            <select name="link" lay-filter="link">
                                <option value=''>请选择链接项目</option>
                              {volist name="category_level_list" id="vo"}
                              <option  value="{$vo.id}">{neq name="vo.level" value="1"}|{php}for($i=1;$i<$vo['level'];$i++){echo ' --';}{/php}{/neq}{$vo.name}</option>
                               {/volist}
                              </select>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">导航名称</label>
                        <div class="layui-input-inline">
                            <input type="text"  id="nav_name" name="name" value="" required lay-verify="required" placeholder="请输入导航名称" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">别名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="alias" value="" placeholder="（选填）请输入导航别名" class="layui-input">
                        </div>
                    </div>
                  
                    <div class="layui-form-item">
                        <label class="layui-form-label">图标</label>
                        <div class="layui-upload">
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn image">上传图片</button>
                                <input type="text" name="icon" class="layui-input" style="position: absolute;left: 111px;top: 0px;width: 500px;">
                            </div>
                            <div class="layui-upload-list">
                                <label class="layui-form-label"></label>
                                <img class="layui-upload-img" id="picshow" style="max-height: 200px">
                                <p id="demoText"></p>
                            </div>
                        </div>
                    </div>
                    <input type="hidden" name="_self" value="_blank">
                    <div class="layui-form-item">
                        <label class="layui-form-label">排序</label>
                        <div class="layui-input-inline">
                            <input type="text" name="sort" value="0" required lay-verify="required" class="layui-input">
                        </div>
                    </div>
                    <div class="btable-paged">
                        <div class="layui-main">
                            <div class="formbtngroup">
                                <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="formadd">添加</button>
                                <button onclick="history.go(-1);return false;" class="layui-btn layui-btn-primary layui-btn-sm">返回</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>


            <div class="layui-tab-item">
                <form class="layui-form form-container" data-url="{:url('admin/navcms/save')}" localtion-url="{:url('navcms/index')}"> 
                    <input type="hidden" name="sid" value="0" title="外部">
                    <div class="layui-form-item">
                            <label class="layui-form-label">导航位置</label>
                            <div class="layui-input-block">
                                <input type="radio" name="pid" value="1" title="顶部" checked="checked">
                                <input type="radio" name="pid" value="0" title="底部">
                                <input type="radio" name="pid" value="2" title="首页中部">
                            </div>
                    </div>
                    <div class="layui-form-item">
                            <label class="layui-form-label">上级分类</label>
    
    
                            <div class="layui-input-inline">

                                <select name="tid">
                                <option value="0">无</option>
                                  {volist name="nav_level_list[1]" id="vo"}
                                <option value="{$vo.id}">{neq name="vo.level" value="1"}|{php}for($i=1;$i<$vo['level'];$i++){echo ' --';}{/php}{/neq}{$vo.name}</option>
                                  {/volist}
                                  </select>
                            </div>
                        </div>    
                  

                 
                    <div class="layui-form-item">
                        <label class="layui-form-label">导航名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="name" value="" required lay-verify="required" placeholder="请输入导航名称" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">别名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="alias" value="" placeholder="（选填）请输入导航别名" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">链接</label>


                        <div class="layui-input-inline" style="width:300px">
                            <input type="text" name="link" value="" placeholder="" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">图标</label>
                        <div class="layui-upload">
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn image">上传图片</button>
                                <input type="text" name="icon" class="layui-input" style="position: absolute;left: 111px;top: 0px;width: 500px;">
                            </div>
                            <div class="layui-upload-list">
                                <label class="layui-form-label"></label>
                                <img class="layui-upload-img" id="picshow" style="max-height: 200px">
                                <p id="demoText"></p>
                            </div>
                        </div>
                    </div>
               
                            <input type="hidden" name="target" value="_blank">
         
                    <div class="layui-form-item">
                        <label class="layui-form-label">排序</label>
                        <div class="layui-input-inline">
                            <input type="text" name="sort" value="0" required lay-verify="required" class="layui-input">
                        </div>
                    </div>
                    <div class="btable-paged">
                        <div class="layui-main">
                            <div class="formbtngroup">
                                <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="formadd">添加</button>
                                <button onclick="history.go(-1);return false;" class="layui-btn layui-btn-primary layui-btn-sm">返回</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>

</div>
{/block} {block name="js"}
<script type="text/javascript" src="__ADMIN__/js/formadd.js"></script>
<script>
    layui.use(['form', 'upload'], function() {
        var form = layui.form,
            upload = layui.upload,
            $ = layui.jquery;
        upload.render({
            elem: '.image',
            url: '{:url("upload/upimage")}',
            before: function(obj) {
                obj.preview(function(index, file, result) {
                    $('#picshow').attr('src', result); //图片链接（base64）
                });
            },
            done: function(res) {
                var item=this.item;
                if (res.code == '0') {
                    console.log($(item).parents().children().find('input[name=pic]'));
                    $(item).parents().children().find('input[name=icon]').val(res.data.src);
                    return layer.msg('上传成功');
                } else {
                    return layer.msg(res.msg);
                }

            }
        });
        form.on('select(link)', function(data){
            $("#nav_name").val($(data.elem).find("option:selected").text().replace(/[|-\s]/g, ''));
        }); 
    })
</script>
{/block}